package com.qbw.app.module.vehicle.holder;

import android.content.Context;
import android.view.ViewGroup;

import com.qbw.app.R;
import com.qbw.app.databinding.VehicleHolderManageItemBinding;
import com.qbw.app.model.Vehicle;
import com.qbw.app.module.common.holder.CommonHolder;
import com.qbw.app.module.vehicle.activity.VehicleDetailActivity;

/**
 * @author QBW
 * @date 2019/9/24
 */
public class VehicleManageItemHolder extends CommonHolder<Vehicle, VehicleHolderManageItemBinding> {

    public VehicleManageItemHolder(Context context, ViewGroup viewParent) {
        super(context, R.layout.vehicle_holder_manage_item, viewParent);
    }

    @Override
    public void bindData(int position, Vehicle data) {
        super.bindData(position, data);
        if("".equals(data.getVehicleNick())){
            mBinding.tvVehicleNick.setText(R.string.twowheel_status);
        }else{
            mBinding.tvVehicleNick.setText(data.getVehicleNick());
        }

        mBinding.setVehicle(data);
        mBinding.executePendingBindings();
        itemView.setOnClickListener(mClickListenerItem);
    }

    @Override
    protected void onClickItem() {
        VehicleDetailActivity.start(mContext, mData.getVehicleCode());
    }
}
